Skip to main content

All Questions

Tagged with
0votes
1answer
203views

Copying an array fails with sed (unterminated `s' command)

i'm trying to copy an array from a running bash script to an external file, but i run into trouble with sed. After hours of searching i still couldn't find an answer, so i thought i post a question ...
Jooch's user avatar
0votes
3answers
4kviews

using sed with variables defined in 2 arrays

I have followed the very many posts on this site regarding the subject but I am still clearly doing something wrong... My goal is to define values in two different arrays, then use sed to search a ...
castaway's user avatar
-1votes
1answer
107views

I am trying to get a value the i just want the last date and time only [closed]

Trying to get a value date and time not the whole log ${1} - Command Line Arguments in Bash ${i} - Array Item in for Loop grep -ERh "stopped" ems_*/SystemOut*.log | tail -1 Now the value is like ...
ChanChan's user avatar
0votes
1answer
653views

Sed search and delete matching two patterns one of which is a variable

I have a file that contains multiple instances of code that I need to delete. Here is an example: !/bin/bash mkdir /rootdir/pipeline_runs/oncology/analysis/sample_1_NA172_1 cd /rootdir/pipeline_runs/...
Don Story's user avatar
1vote
7answers
379views

Create PHP array from letters

I would like to create a PHP array from the Serbian alphabet. Out of а б в г д ђ е ж з и ј к л љ м н њ о п р с т ћ у ф х ц ч џ ш a b c č ć d dž đ e f g h i j k l lj m n nj o p r s š t u v z ž should ...
Luis Paganini's user avatar
3votes
3answers
11kviews

Bash while loop search and replace using sed

I have a problem with my following script (this is the relevant part of it): #!/bin/bash OLD=( "_MAIN1_" "_MAIN2_" ) NEW=( "#111" "#222" ) length=${#OLD[*]} i=0 while (( i < length )) do ...
mazienho's user avatar
1vote
1answer
1kviews

Populate array with a sed/echo combination

I'm trying to rename multiple files containing dates. I want to split the date into year, month and day and then create a new filename in a directory tree like year/month-year/filename_yearmonthday....
bstabens's user avatar
5votes
4answers
616views

Is there an easy way to do the equivalent of `sed ...` replacing the same line with multiple values?

I have a file where I want to replace some variables with data from a shell script. -A INPUT -i lo -s @LOCAL_IP@ -j ACCEPT Here I want to replace @LOCAL_IP@ with an IP address, I use the following: ....
Alexis Wilke's user avatar
2votes
1answer
5kviews

Array indexing using "sed"

I am working on one shell script which search directory modified in last 24 hours and then compress them using tar. Folder Search : find /path to log directory/ -maxdepth 1 -type d -mtime +0 ...
Kunal Sonone's user avatar
1vote
1answer
95views

Array from piped commands fails

First off, apologies if this has been asked before, I searched both here and StackOverflow, tried the man pages, and I'm still drawing a blank. I'm trying to write a script that will auto-mount our ...
Minothor's user avatar
1vote
4answers
136views

Re-print an array in a certain format?

I wish to take 10 random lines of file, which is 100 lines long. First, I randomly generate 10 integers between 1 and 100 (inclusive) with ind=$(shuf -i 1-100 -n 10 | sort -n) Then, I wish to use sed ...
Sibbs Gambling's user avatar
1vote
1answer
3kviews

Problem with sed on a array containing strings containing spaces

I have a array looking like this: array=("(1 2 3) (123)" "2 31 (231)" "4 5 1 (451)" "(te)xt (1234)") This array is a example. It does not look like this but its structure is the same (the strings ...
BrainStone's user avatar

close